name: Common setup
description: Setup necessary environments
inputs:
  job_type:
    description: the name to use in the TEMP_PATH and REPO_COPY
    default: common
    type: string
  nested_job:
    description: the fuse for unintended use inside of the reusable callable jobs
    default: true
    type: boolean
runs:
  using: "composite"
  steps:
    - name: Setup and check ENV
      shell: bash
      run: |
          echo "Setup the common ENV variables"
          cat >> "$GITHUB_ENV" << 'EOF'
          TEMP_PATH=${{runner.temp}}/${{inputs.job_type}}
          EOF
          if [ -z "${{env.GITHUB_JOB_OVERRIDDEN}}" ] && [ "true" == "${{inputs.nested_job}}" ]; then
            echo "The GITHUB_JOB_OVERRIDDEN ENV is unset, and must be set for the nested jobs"
            exit 1
          fi
    - name: Setup $TEMP_PATH
      shell: bash
      run: |
          # to remove every leftovers
          sudo rm -fr "$TEMP_PATH" && mkdir -p "$TEMP_PATH"
